package cn.chrisx.drad.core;

import android.util.Log;
import android.view.ViewGroup;

import cn.chrisx.drad.DrAdSdk;

/**
 * @author Jzfox <jz_boy@163.com>
 * @version 1.0
 * @date 2018/9/21 16:51
 * @description
 * @copyright ©2018 www.jzfox.net All rights reserved.
 */
public abstract class DrAdConfig {

    // 广告应用 id，有的广告不需要这个
    private String appId;

    //  广告位 id
    private String adUnitId;

    // banner 广告需要的容器
    private ViewGroup adContainer;

   // 仅为调试模式时使用
    private boolean onlyDebug;

    public DrAdConfig() {

        String name = checkPlatform();

        if (DrAdSdk.DEV_DEBUG) {
            Log.d(DrAdConfig.class.getSimpleName(), "checked:" + name);
        }

        // 将配置信息注册进去
        DrAdSdk.registerAdPlatform(platform());
    }

    public DrAdConfig setAdUnitId(String adUnitId) {
        this.adUnitId = adUnitId;
        return this;
    }

    public DrAdConfig setAppId(String appId) {
        this.appId = appId;
        return this;
    }

    public void setAdContainer(ViewGroup adContainer) {
        this.adContainer = adContainer;
    }

    public ViewGroup getAdContainer() {
        return adContainer;
    }

    public String getAppId() {
        return appId;
    }

    public String getAdUnitId() {
        return adUnitId;
    }

    protected abstract String checkPlatform();

    public abstract DrAdPlatform platform();

    public boolean isOnlyDebug() {
        return onlyDebug;
    }

    public void setOnlyDebug(boolean onlyDebug) {
        this.onlyDebug = onlyDebug;
    }
}
